package com.prs.crm.dao.hr.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.hr.SalaryRelatDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.hr.Salary;
import com.prs.crm.domain.hr.SalaryRelat;

public class SalaryRelatDaoImpl extends BaseDaoImpl<SalaryRelat> implements SalaryRelatDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<SalaryRelat> getSalaryRelat(final Salary salary) {
		return (List<SalaryRelat>) this.getHibernateTemplate().execute(
				new HibernateCallback() {
					public Object doInHibernate(Session session)
							throws HibernateException {
						Criteria criteria = session
								.createCriteria(SalaryRelat.class);
						criteria.add(Restrictions.eq("salary", salary));
						List<SalaryRelat> result = criteria.list();

						return result;

					}
				});
	}

}
